<!DOCTYPE html>
<html  xmlns="http://www.w3.org/1999/xhtml"
       xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <script th:src="@{static/js/vue.js}"></script>
    <script th:src="@{static/js/elementUI.js}"></script>
    <script th:src="@{static/js/axios.js}"></script>
    <link th:href="@{static/css/elementUI.css}" rel="stylesheet" />
    <style>
        /**/
        .text {
            font-size: 15px;
        }

        .item {
            margin-bottom: 5px;
        }
        .clearfix:before,
        .clearfix:after {
            display: table;
            content: "";
        }
        .clearfix:after {
            clear: both
        }

        .box-card {
            width: 100%;
        }
        #main{
            width: 80%;
            margin: auto;
            margin-top: 10px;
        }
        #dataTable{
            margin-top: 10px;
        }
        #form{
            line-height: 60px;
        }
        #top{
            /*height: 100px;*/
            /*overflow: hidden;*/
        }
        div{
            /*border: 1px red solid;*/
        }
    </style>
</head>

<body>
<div id="top">
    <el-card class="box-card" style="background-color: #EBEEF5">
        <span style="margin-left: 9%;margin-top: 5px;background-color: #3a8ee6;font-size: 15px">&nbsp;&nbsp;</span>
        <span style="font-size: 15px;margin-left: 10px">产品审核</span>
        <el-button type="primary" size="small" icon="el-icon-refresh" style="float: right;margin-right: 170px">刷新</el-button>    </el-card>
</div>
<div id="main">
    <div id="form">
        <el-card class="box-card">
            <div slot="header" class="clearfix" style="height: 20px;line-height: 20px">
                <span style="font-size: 15px">筛选查询</span>
                <el-button style="float: right; padding: 3px 0" type="text" @click=advSear()>高级搜索</el-button>

                <div id="medel_box">
                    <el-dialog title="高级搜索" :visible.sync="searchDialogFormVisible">

                        <el-form :inline="true" :model="form" ref="form" class="demo-form-inline">
                            <el-form-item label="输入搜索:" style="margin-left: 10px" prop="product_name">
                                <el-input v-model="form.product_name" placeholder="请输入产品名称" style="margin-top: 15px"></el-input>
                            </el-form-item>

                            <el-form-item label="资金方:" style="margin-left: 10px" prop="channel_id">
                                <el-select v-model="form.channel_id" clearable placeholder="请选择资金方" style="margin-top: 15px">
                                    <el-option
                                        v-for="item in tableData"
                                        :key="item.channelBean.id"
                                        :label="item.channelBean.companyName"
                                        :value="item.channelBean.id">
                                    </el-option>

                                </el-select>
                            </el-form-item>

                            <el-form-item label="还款方式:" style="margin-left: 10px" prop="repay_way">
                                <el-select v-model="form.repay_way" clearable placeholder="请选择还款方式" style="margin-top: 15px">
                                    <el-option label="等本等息" value="0"></el-option>
                                    <el-option label="等本无息" value="1"></el-option>
                                </el-select>
                            </el-form-item>

                            <el-form-item label="上下架:" style="margin-left: 10px" prop="product_status">
                                <el-select v-model="form.product_status" clearable placeholder="请选择产品状态" style="margin-top: 15px">
                                    <el-option label="已上架" value="1"></el-option>
                                    <el-option label="已下架" value="0"></el-option>
                                </el-select>
                            </el-form-item>

                        </el-form>

                        <div slot="footer" class="dialog-footer">
                            <el-button @click="resetForm('form')">重置</el-button>
                            <el-button @click="searchDialogFormVisible = false">取 消</el-button>
                            <el-button type="primary" @click=advancedSearch()>确 定</el-button>
                        </div>
                    </el-dialog>
                </div>
            </div>
            <div align="left">
                <el-form :inline="true" :model="formInline" ref="formInline" class="demo-form-inline">
                    <el-form-item label="输入搜索:" style="margin-left: 10px" prop="product_name">
                        <el-input v-model="formInline.product_name" placeholder="请输入产品名称" style="margin-top: 15px"></el-input>
                    </el-form-item>

                    <el-form-item label="资金方:" style="margin-left: 10px" prop="channelBean.id">
                        <el-select v-model="formInline.channelBean.id" clearable placeholder="请选择资金方" style="margin-top: 15px">
                            <el-option
                                    v-for="item in tableData"
                                    :key="item.channelBean.id"
                                    :label="item.channelBean.companyName"
                                    :value="item.channelBean.id">
                            </el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item label="还款方式:" style="margin-left: 10px" prop="repay_way">
                        <el-select v-model="formInline.repay_way" clearable placeholder="请选择还款方式" style="margin-top: 15px">
                            <el-option label="等本等息" value="0"></el-option>
                            <el-option label="等本无息" value="1"></el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item>
                        <el-button type="primary" icon="el-icon-search" @click="onSubmit" style="margin-top: 15px">查询</el-button>
                        <el-button @click="resetForm('formInline')">重置</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </el-card>
    </div>
    <div id="dataTable">
        <el-card class="box-card">
            <div slot="header" class="clearfix">
                <span style="font-size: 15px">数据列表</span>
            </div>
            <template>
                <!--  给表格绑定数据，tableData即为后端传过来的数据  -->
                <el-table
                        :data="tableData"
                        ref="multipleTable"
                        border
                        style="width: 100%">
                    <!--  用porp给这一列绑定 tableData中对应的属性 ，type=selection表示这一列是复选框 -->
                    <el-table-column
                            prop="id"
                            type="selection"
                            align="center">
                    </el-table-column>
                    <!--  label="产品编号"表示这一列的表头是“产品编号”,width代表这一列宽度 -->
                    <el-table-column
                            prop="productNum"
                            label="产品编号"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="productName"
                            label="产品名称"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="channelBean.companyName"
                            label="资金方"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="repayWay"
                            label="还款方式"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="checkStatus"
                            label="审核状态"
                            align="center">
                    </el-table-column>

                    <el-table-column
                            label="操作"  align="center">
                        <template scope="scope">
                            <el-button style="float:left;margin-left: 60px; padding: 3px 0" type="text"
                                       @click=product_view(scope.row)>查看</el-button>
                            <div id="medel_box2">
                                <el-dialog :title="title" :visible.sync="updateDialogFormVisible" >
                                    <el-form :inline="true" :model="productForm" ref="productForm">
                                        <el-form-item label="产品编号" >
                                            <el-input v-model="productForm.productNum" :disabled="true" autocomplete="off"></el-input>
                                        </el-form-item>

                                        <el-form-item label="产品名称" >
                                            <el-input v-model="productForm.productName" :readonly="true" autocomplete="off"></el-input>
                                        </el-form-item>

                                        <el-form-item label="资金方" >
                                            <el-input v-model="productForm.channelBean.companyName" :disabled="true" autocomplete="off"></el-input>
                                        </el-form-item>

                                        <el-form-item label="还款方式" >
                                            <el-select v-model="productForm.repayWay" placeholder="请选择还款方式" >
                                                <el-option label="等本等息" value="0"></el-option>
                                                <el-option label="等本无息" value="1"></el-option>
                                            </el-select>
                                        </el-form-item>

                                        <el-form-item label="产品介绍" >
                                            <el-input
                                                    type="textarea"
                                                    autosize
                                                    placeholder="请输入内容"
                                                    v-model="productForm.intorduce">
                                            </el-input>
                                        </el-form-item>

                                        <el-form-item label="借款期限(月)" >
                                            <el-input v-model="productForm.loanLife" autocomplete="off"></el-input>
                                        </el-form-item>

                                        <el-form-item label="月利率(%)" >
                                            <el-input v-model="productForm.monthRate" autocomplete="off"></el-input>
                                        </el-form-item>

                                        <el-form-item label="产品状态" >
                                            <el-input v-model="productForm.productStatus" autocomplete="off"></el-input>
                                        </el-form-item>

                                        <el-form-item label="详细页标题" >
                                            <el-input v-model="productForm.title" autocomplete="off"></el-input>
                                        </el-form-item>

                                        <el-form-item label="详细页描述" >
                                            <el-input v-model="productForm.productDesc" autocomplete="off"></el-input>
                                        </el-form-item>

                                        <el-form-item label="产品备注" >
                                            <el-input v-model="productForm.remark" autocomplete="off"></el-input>
                                        </el-form-item>

                                    </el-form>
                                </el-dialog>
                            </div>

                            <el-button style="padding: 3px 0;float: left;margin-left: 20px" type="text" @click=product_check(scope.row)>审核</el-button>
                           <div id="medel_box4">
                                <el-dialog title="产品审核" :visible.sync="proCheckDialogFormVisible" >
                                    <el-form :inline="true"  :model="productCheckForm" ref="productCheckForm">
                                        <el-form-item label="产品名称:" >
                                            <el-input v-model="productCheckForm.productBean.productName" autocomplete="off"></el-input>
                                        </el-form-item>

                                        <el-form-item label="产品审核:" >
                                                <el-radio-group v-model="productCheckForm.checkResult">
                                                    <el-radio :label="1">审核通过</el-radio>
                                                    <el-radio :label="0">审核不通过</el-radio>
                                                </el-radio-group>
                                        </el-form-item>

                                        <el-form-item label="反馈详情:" >
                                            <el-input
                                                    type="textarea"
                                                    autosize
                                                    placeholder="请输入内容"
                                                    v-model="productCheckForm.feedback">
                                            </el-input>
                                        </el-form-item>
                                    </el-form>
                                    <div slot="footer" class="dialog-footer">
                                        <el-button @click="proCheckDialogFormVisible = false">取 消</el-button>
                                        <el-button type="primary" @click=pro_checked(scope.row)>确定</el-button>
                                    </div>
                                </el-dialog>
                            </div>
                        </template>

                    </el-table-column>
                </el-table>
            </template>

            <template>
                <div class="block" style="float: right;margin-top: 30px">
                    <!-- size-change绑定的是每页显示数量变化时执行的方法，
                     current-change绑定的是翻页时执行的方法，
                     page-sizes属性中的数组是 “每页显示多少条” 下拉框中的数据，
                     page-size属性时当前显示条数，
                     layout是翻页控件的布局顺序，
                     total绑定的是总共多少条数据-->
                    <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="currentPage"
                            :page-sizes="[10, 15, 20, 25]"
                            :page-size="pageSize"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="total">
                    </el-pagination>
                </div>
            </template>
        </el-card>
    </div>
</div>
<script th:inline="javascript">
    let app = new Vue({
            el:'#main',
            data:{
                //表格数据
                tableData:[],
                //总条数
                pageSize:10,
                //当前页
                currentPage:1,
                total:0,
                formInline: {//普通搜索
                    product_name: '',
                    channelBean: '',
                    repay_way:''
                },
                //高级搜索
                searchDialogFormVisible:false,
                form:{
                    product_name: '',
                    channel_id: '',
                    repay_way:'',
                    product_status:'',
                    check_status:''
                },
                //查看产品详情
                updateDialogFormVisible:false,
                title:'',
                productForm:{
                    id:'',
                    productNum:'',
                    productName:'',
                    channelBean:'',
                    repayWay:'',
                    intorduce:'',
                    loanLife:'',
                    monthRate:'',
                    productStatus:'',
                    title:'',
                    productDesc:'',
                    remark:''
                },

                //审核
                proCheckDialogFormVisible:false,
                productCheckForm:{
                    id:'',
                    productBean:'',
                    checkResult:'',
                    feedback:''
                },


            },
            methods:{
                //重置普通搜索表单
                resetForm(formInline) {
                    this.$refs[formInline].resetFields();
                },

                //向后端发起请求，加载表格内容，传的参数是当前查第几页
                getData(val){
                    axios.get([[@{product/page}]],{
                        params:{
                            //每页多少条
                            limit:this.pageSize,
                            //从什么地方开始查
                            offSet:0,
                            //当前查第几页
                            pageNum:val,
                            //排序字段和排序方式
                            sort:"id",
                            sortOrder:"asc",
                            //要传属性的继续写在下面

                        }
                    }).then(res => {
                        //将查询到的数据赋给表格中绑定的变量
                        this.total = res.data.total;
                        this.tableData = res.data.rows;
                        for(let i = 0 ;i<this.tableData.length;i++) {
                            if (this.tableData[i].checkStatus === 1) {
                                this.tableData[i].checkStatus = "已审核";
                            } else {
                                this.tableData[i].checkStatus = "未审核";
                            }
                        }
                    }).catch(error => {
                        console.log(error);
                    })
                },
                //改变每页显示数据条数时执行的方法
                handleSizeChange(val){
                    this.pageSize=val;
                    this.currentPage=1;
                    this.getData(this.currentPage);
                },
                //翻页时执行的方法
                handleCurrentChange(val) {
                    this.currentPage=val;
                    this.getData(this.currentPage);
                },
                change:function(index,row){
                    console.log(index,row);
                },

                //点击编辑时弹出模态框
                product_view(row){
                    this.updateDialogFormVisible = true;
                    this.title="产品详情";

                    this.productForm.id = row.id;
                    this.productForm.productNum= row.productNum;
                    this.productForm.productName= row.productName;
                    this.productForm.channelBean= row.channelBean;
                    this.productForm.repayWay= row.repayWay;
                    this.productForm.intorduce= row.intorduce;
                    this.productForm.loanLife= row.loanLife;
                    this.productForm.monthRate= row.monthRate;
                    if (row.productStatus === 0){
                        this.productForm.productStatus="未上架"
                    }else{
                        this.productForm.productStatus="已上架"
                    };
                    this.productForm.title= row.title;
                    this.productForm.productDesc= row.productDesc;
                    this.productForm.remark= row.remark;
                },
                //点击审核时弹出模态框
                product_check(row){
                    this.proCheckDialogFormVisible=true;
                    this.productCheckForm.id = row.id;
                    this.productCheckForm.productBean.productNum= row.productNum;
                },

                //点击高级搜索时弹出模态框
                advSear(){
                    this.searchDialogFormVisible = true;
                },

                //普通搜索表单提交
                onSubmit() {
                    axios.get([[@{product/page}]],{
                        params:{
                            //每页多少条
                            limit:this.pageSize,
                            //从什么地方开始查
                            offSet:0,
                            //当前查第几页
                            pageNum:1,
                            //排序字段和排序方式
                            sort:"id",
                            sortOrder:"asc",
                            //要传属性的继续写在下面
                            productName:this.formInline.product_name,
                            channelBean:this.formInline.channelBean,
                            repayWay:this.formInline.repay_way
                        }
                    }).then(res => {
                        //将查询到的数据赋给表格中绑定的变量
                        this.total = res.data.total;
                        this.tableData = res.data.rows;
                        for(let i = 0 ;i<this.tableData.length;i++){
                            if(this.tableData[i].productStatus === 0){
                                this.tableData[i].productStatus = true;
                            }
                        }
                    }).catch(error => {
                        console.log(error);
                    })
                }
            },
            //高级搜索表单提交
            /*advancedSearch() {
                axios.get([[@{channel/page}]],{
                    params:{
                        //每页多少条
                        limit:this.pageSize,
                            //从什么地方开始查
                            offSet:0,
                            //当前查第几页
                            pageNum:1,
                            //排序字段和排序方式
                            sort:"create_time",
                            sortOrder:"desc",
                            //要传属性的继续写在下面
                            companyName:this.form.company_name,
                            companyArea:this.form.company_area,
                            channelLevel:this.form.channel_level,
                            createTime:this.form.create_time,
                            status:this.form.status,
                            source:this.form.source
                    }
                }).then(res => {
                    //将查询到的数据赋给表格中绑定的变量
                    this.total = res.data.total;
                    this.tableData = res.data.rows;
                    for(let i = 0 ;i<this.tableData.length;i++){
                        if(this.tableData[i].status === 0){
                            this.tableData[i].status = true;
                        }
                    }
                }).catch(error => {
                    console.log(error);
                })
            }
        },*/
            //创建时执行查询，查第一页
            created : function () {
                this.getData(1);
            }
    })
    let app3 = new Vue({
        el:"#top"
    })
</script>
</body>
</html>